package main

import (
	proxy2 "gin-gateway/example/gateway_demo/otherProxy/proxy"
	"log"
	"net/http"
	"gin-gateway/example/gateway_demo/otherProxy/load_balance"
	"gin-gateway/example/gateway_demo/otherProxy/middleware"
)

var (
	addr = "127.0.0.1:2002"
)

func main() {
	lbCheckConf, err := load_balance.NewLoadBalanceCheckConf("http://%s/base", map[string]string{"127.0.0.1:2003": "20", "127.0.0.1:2004": "20"})
	if err != nil {
		panic(err)
	}
	lb := load_balance.LoadBanlanceFactorWithConf(load_balance.LbWeightRoundRobin, lbCheckConf)
	proxy := proxy2.NewLoadBalanceReverseProxy(&middleware.SliceRouterContext{}, lb)
	log.Println("Starting httpserver at " + addr)
	log.Fatal(http.ListenAndServe(addr, proxy))
}
